package com.tgy.基础学习.Thread.Synchronized;

import java.util.ArrayList;

/**
 * @author 送你一块二向箔
 * @date 2021/11/08 16:27
 */
/*
线程不安全的集合
 */
public class UnsafeList {
    public static void main(String[] args) throws InterruptedException {
        ArrayList<String> list = new ArrayList<>();
        for (int i = 0; i < 10000; i++) {
            new Thread(()->{
                list.add(Thread.currentThread().getName());
            }).start();
        }
        Thread.sleep(3000);
        System.out.println(list.size());
    }
}
